
--#include "data\config\activityconfig\HookMap\HookMapConfig.lua" once


function BuyTimesByGold( sysarg )
	return BuyTimes(sysarg, mtYuanbao)
end


function BuyTimesByBindGold( sysarg )
	return BuyTimes(sysarg, mtBindYuanbao)
end

function BuyTimes( sysarg, coinType )
	local dlgStr = ""
	local moneyName = moneyTypeName[coinType]
	for k, v in ipairs(HookMapConfig.BuyTimes) do
		local funcStr = string.format(Lang.ScriptTips.hook001, v[1], v[2], moneyName)
		dlgStr = string.format("%s\n<#BL%s/@BuyTimeFunc,%d,%d, 1>", dlgStr, funcStr, k, coinType)
	end
	return dlgStr .. Lang.ScriptTips.back001
end

function cancelBtn( sysarg )

end

function BuyTimeFunc( sysarg, tabIdx, coinType, notice )
	tabIdx = tonumber(tabIdx)
	coinType = tonumber(coinType)
	local cfg = HookMapConfig.BuyTimes[tabIdx]
	if not cfg then
		return
	end
	if not Actor.checkActorLevel(sysarg, HookMapConfig.MinLevel, 0) then
		Actor.sendTipmsg(sysarg, string.format(Lang.ScriptTips.hook008, HookMapConfig.MinLevel), ttFlyTip)
		return
	end
	local moneyName = moneyTypeName[coinType]
	local moneyPropId = moneyTypeMap[coinType]
	local myMoney = Actor.getIntProperty( sysarg, moneyPropId)
	if myMoney < cfg[2] then
		Actor.sendTipmsg(sysarg, string.format(Lang.ScriptTips.hook006, cfg[1], cfg[2], moneyName), ttFlyTip)
		return 
	end
	if notice then
		local npcHandle = Actor.getHandle(thisNPC)
		local noticeStr = string.format(Lang.ScriptTips.hook012, cfg[2], moneyName, cfg[1])
		local okBtn = string.format("%s/BuyTimeFunc,%d,%d", Lang.ScriptTips.x00050, tabIdx, coinType)
		local cancelBtn = string.format("%s/cancelBtn", Lang.ScriptTips.x00051)
		Actor.messageBox(sysarg, npcHandle, 0, noticeStr, okBtn, cancelBtn, NULL)
	else
		if cfg[2] > 0 and Actor.changeMoney(sysarg, coinType, -cfg[2], GameLog.clEquipBrokedMoney, Lang.LogTips.yb007) then
			local v = HookMapConfig.buff
			Actor.addBuff( sysarg, v.buffType, v.groupId, v.value, cfg[1], v.interval, v.buffName, v.timeOverlay)
			local sceneName = Actor.getSceneName(sysarg, 0, 0)
			if sceneName ~= Lang.SceneName.s00008 then
				local mapTime = Actor.getBuffRemainTime(sysarg, v.buffType, v.groupId)
				Actor.initActivityWind(sysarg, Lang.Activity.map0001, mapTime, Lang.Activity.map0002)
			end
			Actor.sendTipmsg(sysarg, string.format(Lang.ScriptTips.hook014, cfg[1]), ttFlyTip)
		end
	end
end

function IsTodayGetBuff( sysarg )
	local actorVar = Actor.getStaticVar(sysarg)
	if actorVar.HookMapBuff then
		local y = 0
		local m = 0
		local d = 0
		y,m,d = System.getDate( y, m, d )
		local curDt = y * 10000 + m *100 + d
		return curDt <= actorVar.HookMapBuff
	end
	return false
end

--设置itemId在今天使用过几次
function SetTodayGetBuff( sysarg )
	local actorVar = Actor.getStaticVar(sysarg)
	local y = 0
	local m = 0
	local d = 0
	y,m,d = System.getDate( y, m, d )
	local curDt = y * 10000 + m *100 + d
	actorVar.HookMapBuff = curDt
end

function IsInHoopMap(sysarg)
	local nSceneId = Actor.getSceneId(sysarg)
	local sname = Fuben.getSceneNameById(nSceneId)
	for k, sceneName in ipairs(HookMapConfig.SceneNames) do
		if sceneName == sname then
			return true
		end
	end
	return false
end

function ExitFromHoopMap(sysarg)
	Actor.enterScene(sysarg,HookMapConfig.ExitAreaPos[1],HookMapConfig.ExitAreaPos[2],HookMapConfig.ExitAreaPos[3])
end